package com.dubbo.server.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.NotBlank;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.dubbo.api.DeptService;
import com.dubbo.entity.DeptDo;

@Service(interfaceClass = DeptService.class)
@Component
public class DeptServiceImpl implements DeptService {
	
	@SuppressWarnings("serial")
	private List<DeptDo> depts = new ArrayList<DeptDo>() {
		{
			add(new DeptDo(1L, "销售部"));
			add(new DeptDo(2L, "技术部"));
			add(new DeptDo(3L, "运维部"));
		}
	};

	
	@Override
	public DeptDo findById(@NotBlank Long id) {	
		return depts.stream().filter(dept -> dept.getDeptId() == id).findFirst().get();
	}

	@Override
	public List<DeptDo> deptList() {
		return depts;
	}

}